package com.foreknow.tijian.controller;

import com.foreknow.tijian.po.Hospital;
import com.foreknow.tijian.service.HospitalService;
import com.foreknow.tijian.service.Impl.HospitalServiceImpl;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

public class HospitalController {
    public Object listHospital(HttpServletRequest request) {
        List<Hospital> hospitals = new ArrayList<Hospital>();
        //1.获取前台的请求参数
        Hospital hospital = new Hospital();
        int state = Integer.parseInt(request.getParameter("state"));
        hospital.setState(state);
        //2.调用Service当中的方法
        HospitalService hospitalService = new HospitalServiceImpl();
        hospitals= hospitalService.listHospital(hospital);
        return hospitals;
    }

    public Object getHospitalById(HttpServletRequest request) {
        Hospital hospital = new Hospital();
        int hospitalId = Integer.parseInt(request.getParameter("hpId"));
        hospital.setHpId(hospitalId);
        HospitalService hospitalService = new HospitalServiceImpl();
       hospital= hospitalService.getHospitalById(hospital);
       return hospital;
    }
}
